<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="24">
        <SearchForm
          v-show="showSearch"
          v-model="queryParams"
          :options="options.formOps"
          @onQuery="getList"
        >
        </SearchForm>
        <el-row :gutter="10" class="mb8">
          <right-toolbar
            v-model:showSearch="showSearch"
            @queryTable="getList"
          ></right-toolbar>
        </el-row>
        <Table
          ref="table"
          :auto-featch="true"
          :fetch-data="fetchData"
          :options="options.table"
          :useAction="false"
          :usePage="false"
        >
        </Table>
      </el-col>
    </el-row>
  </div>
</template>

<script setup>
import Table from "@/components/Table/index.vue";
import SearchForm from "@/components/searchForm/index";
import formJson from "./components/options.json";
import { apis as APIS } from "@/api/hdwarning/immediate.js";
import { useAsyncData, useFormJsonNew } from "@/views/hooks/useAsyncData.js";
import { deptTreeSelect } from "@/api/system/user";
const { proxy } = getCurrentInstance();

const ops = useFormJsonNew(formJson, {
  sort: [],
  sortable: [],
});
const options = reactive({
  table: ops,
  formOps: ops.filter((i) =>
    [
      "interlockNumber",
      "interlockActionNumber",
      "interlockRelation",
      "interlockActionDescription",
    ].includes(i.prop)
  ),
});
const showSearch = ref(true);
const table = ref();

const { fetchData, getList, queryParams } = useAsyncData({
  APIS: {
    query: APIS.aqyb,
  },
  formJson,
  table,
  proxy,
});
const deptTree = ref([]);
onMounted(() => {
  deptTreeSelect().then((response) => {
    deptTree.value = response.data;
  });
});
</script>

<style lang="scss" scoped>
::v-deep.el-form-item__label {
  text-align: right !important;
}
</style>
